<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="/auto/Css/base.css">
    <link rel="stylesheet" href="/auto/Css/lib.css">
    <link rel="shortcut icon" href="/auto/favicon.ico" type="image/x-icon">
    <link rel="stylesheet" href="/auto/Css/Personal.css">
    <link href="/auto/Css/index.css">
    <script src="/admin/qrcode/jquery2.1.4.js"></script>
    <script src="/admin/layer/layer.js"></script>
</head>
<body>
<!-- top bar -->
<div class="top_bar">
    <div class="top_bar_con">
        <div class="top_bar_left">
            <img src="/auto/images/logo.png" alt="">
            <img src="/auto/images/slogan.svg" alt="">
        </div>
        <div class="top_bar_search clearfix">
            <form action="">
                <input type="text" class="search-input" name="keyword" placeholder="搜索品牌、车型等" id="search-input">
                <i class="fa fa-search "></i>
                <input type="submit" class="search-btn" value="搜索" bosszone="search">
            </form>
        </div>
        <div class="top_bar_right">
            <a href="/end/auto/index.html" class="active">首页</a>
            <a href="/end/auto/VehicleScre.html">选车</a>
            <a id="userCollect">我的收藏</a>
            <button id="loading">请登录</button>
            <a href="javascript:;" id="user"></a>
            <button id="loginOut">退出</button>
        </div>
    </div>
</div>

<!-- 个人主页 -->
<div class="personal_text">
    <div class="personal">
        <div class="personal_img">
            <img src="/auto/images/personal.jpg" alt="">
        </div>
        <div>
            <p id="name">张三</p>
        </div>
    </div>

    <div class="personal_con">
        <p>收藏车型</p>
        <div class="personal_main" id="str">
            <div>
                <div>
                    <img src="/auto/images/5dc831d58ea34affbd5b7d09f20eac36.png" alt="">
                </div>
                <div>
                    <p>帕萨特</p>
                    <span>指导价：18.88万</span>
                </div>

                <div>
                    <a href="">询底价</a>
                </div>
            </div>
        </div>
    </div>
</div>

<!-- 首页底部 -->
<div class="bottom_bar">
    <div class="custom_ser">
        <div class="custom_ser_main">
            <div>
                <span>周一至周五</span><br>
                <span>9:00-17:00</span>
            </div>
            <div>
                <h4>175-3012-3061</h4>
                <p>商城客服热线</p>
            </div>
            <div>
                <img src="/auto/images/1210339.png" alt="">
            </div>
            <div>
                <h3>扫码享权益</h3>
                <p>优惠随时掌握</p>
            </div>
        </div>
    </div>
    <div class="about_us">
        <div class="about_us_main">
            <ul>
                <li>
                    <a href="#">关于我们</a>
                </li>
                <li>
                    <a href="#">About Us</a>
                </li>
                <li>
                    <a href="#">隐私政策</a>
                </li>
                <li>
                    <a href="#">联系我们</a>
                </li>
                <li>
                    <a href="#">客服中心</a>
                </li>
            </ul>
            <br>
            <p>Copyright © 2021 - 2022 Car Shop. All Rights Reserved</p>
            <p>汽车商城 版权所有</p>
        </div>
    </div>
</div>

<script>
    //判断是否登录
    $(function () {
        $.ajax({
            type: "POST",
            url: "/Login/LoginBy",
            data: "",
            dataType: "json",
            success: function (data) {
                if (data.code === 200) {
                    $("#loading").hide();
                    $("#user").html(data.obj.userName);
                    $("#name").html(data.obj.userName);
                    let id = data.obj.userId;
                    //获取收藏车辆
                    $.ajax({
                        type: "GET",
                        url: "/User/queryByUserId",
                        data: {userId:id},
                        dataType: "json",
                        success: function (vo) {
                            let str="";
                            for (let i = 0;i<vo.length;i++){
                                let obj = vo[i];
                                console.log(obj.priceMax)
                                let priceMin = obj.priceMin != "" ? obj.priceMin / 10000 : 0;
                                priceMin = priceMin.toFixed(2);
                                let priceMax = obj.priceMax != "" ? obj.priceMax / 10000 : 0;
                                priceMax = priceMax.toFixed(2);
                                str+='<div>' +
                                    '<div>\n' +
                                    '                    <img src="/assets/images/carName/'+obj.picture+'" alt="">\n' +
                                    '                </div>\n' +
                                    '                <div>\n' +
                                    '                    <p>'+obj.carName+'</p>\n' +
                                    '                    <span>' +priceMin + ' - ' + priceMax + '万元</span>\n' +
                                    '                </div>\n' +
                                    '\n' +
                                    '                <div>\n' +
                                    '                    <a href="/end/auto/reservePrice.html?id=' + obj.id +
                                    '">询底价</a>\n' +
                                    '                </div>' +
                                    '</div>'
                            }
                            $("#str").html(str)
                        }
                    })

                } else {
                    $("#loginOut").hide();
                }
            }
        })
    })
    loginOut.onclick = function () {
        $.ajax({
            type: "post",
            url: "/Login/userLogout",
            data: "",
            dataType: "json",
            success: function (data) {
                alert(data.msg);
                location.href = "/end/auto/index.html";
            }
        })
    }

</script>
</body>
</html>